<template>
	<view class="pages-index">
		<view class="top-box">
			<image :src="baseOssUrl2 + form.headPhoto" style="width: 100%;height: 100%;" mode=""></image>
		</view>
		<view class="text-box">
			<view class="tops-box">
				<view class="name-box">
					{{form.title}}
				</view>
				<view class="num">
					￥{{form.dj}}
				</view>
			</view>
	<!-- 		<view class="sl-box">
				<view class="text">
					数量
				</view>
				<view class="textnum">
					{{form.sl}}
				</view>
			</view> -->
		</view>
<!-- 		<view class="title-box">
			{{form.title}}
		</view>
		<view class="title-boxss">
			<view class="">
				商品价格
			</view> 
			<view class="textssss">
				￥{{form.dj}}
			</view>
		</view> -->
		<view class="image-box">
			<image class="a" v-for="(item,index) in form.images" :key="index" :src="baseOssUrl2 + item" mode="widthFix"></image>
		</view>
		<view class="bnts-box" @click="ljBnt(form.id)">
			<view class="bnrt">
				<view class="bnrts">
					￥{{form.dj}}
				</view>
				<view class="bnrtss">
					立即购买
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		baseOssUrl,
		baseOssUrl2
	} from '@/common/settings';
	export default {
		data() {
			return {
				form:{},
				id:'',
				baseOssUrl: baseOssUrl,
				baseOssUrl2:baseOssUrl2,
			}
		},
		onLoad(e) {
			this.id = e.id
			this.detail()
		},
		methods: {
			// 详情
			detail() {
				this.$http.get(this.$httpApi.creativegoodsqueryByid, {
					data: {
						 id: this.id,
					}
				}).then(res => {
					if (res.code == 0) {
						this.form = res.creativeGoods
						var arr = [];
						arr  = res.creativeGoods.images.split(',')
						this.form.images = arr
						console.log(this.form.images)
					}
				})
			},
			// 购买
			ljBnt(e) {
				if(this.form.sl == 0) {
					uni.showToast({
						icon: 'none',
						title: '商品已售空!',
						duration: 2000
					});
					return
				}
				uni.navigateTo({
					url:'/pages/writing/buy/index?id=' + e
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.pages-index {
		background: #EFEFEF;
		min-height: 100vh;
		padding-bottom: 150rpx;
		.top-box {
			width: 750rpx;
			height: 550rpx;
			background: #F7F7FA;
		}
		.text-box {
			padding: 32rpx;
			margin-bottom: 20rpx;
			background: #FFFFFF;
			.tops-box {
				display: flex;
				align-items: center;
				.name-box {
					font-size: 30rpx;
					color: #1D1D1D;
				}
				.num {
					margin-left: auto;
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					color: #D93C3C;
				}
			}
			.sl-box {
				margin-top: 20rpx;
				display: flex;
				align-items: center;
				.text{
					font-size: 30rpx;
					font-weight: bold;
					color: #1D1D1D;
				}
				.textnum {
					margin-left: auto;
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: bold;
					color: #1D1D1D;
				}
			}
		}
		.title-box{
			margin-left: 32rpx;
			margin-top: 40rpx;
			margin-bottom: 24rpx;
			font-size: 30rpx;
			font-weight: bold;
			color: #1D1D1D;
		}
		.title-boxss {
			display: flex;
			align-items: center;
			justify-content: center;
			margin-left: 32rpx;
			margin-right: 32rpx;
			margin-top: 40rpx;
			margin-bottom: 24rpx;
			font-size: 30rpx;
			font-weight: bold;
			color: #1D1D1D;
			.textssss {
				margin-left: auto;
				color: red;
			}
		}
		.image-box {
			margin-left: 32rpx;
			margin-right: 32rpx;
			.a {
				border-radius: 16rpx;
				width: 100%;
			}
		}
		.bnts-box {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 750rpx;
			height: 160rpx;
			background: #FFFFFF;
			box-shadow: 0px 3rpx 6rpx 1rpx rgba(0,0,0,0.16);
			display: flex;
			align-items: center;
			justify-content: center;
			.bnrt {
				border-radius: 30rpx ;
				width: 686rpx;
				height: 100rpx;
				background: #35743D;
				font-size: 28rpx;
				font-weight: bold;
				color: #FFFFFF;
				.bnrts {
					margin-top: 10rpx;
					border-radius: 30rpx 30rpx 0rpx 0rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 686rpx;
					background: #35743D;
					font-size: 28rpx;
					font-weight: bold;
					color: #FFFFFF;
				}
				.bnrtss {
					border-radius: 0rpx 0rpx 30rpx 30rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 686rpx;
					background: #35743D;
					font-size: 28rpx;
					font-weight: bold;
					color: #FFFFFF;
				}
			}
		}
	}
</style>
